Migrate UI Hooks to @kubernetesjs/react and Implement Namespace Context #13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Migrate UI Hooks to @kubernetesjs/react and Implement Namespace Context
Summary
This PR migrates all UI hooks from the custom
KubernetesContext
to use the generated hooks from@kubernetesjs/react
package, implements a newNamespaceContext
for global namespace management, and adds support for_all
namespace for cluster-wide queries.Changes Made
🔄 Context Migration
ui/contexts/KubernetesContext.tsx
- deprecated custom contextui/contexts/NamespaceContext.tsx
- new namespace management contextui/app/providers.tsx
- now usesKubernetesProvider
from@kubernetesjs/react/context
and newNamespaceProvider
🎣 Hook Migration
Migrated all hooks in
ui/hooks/
to use generated React Query hooks:useNamespaces.ts
- namespace management hooksusePods.ts
- pod management with cluster-wide supportuseDeployments.ts
- deployment management with scalinguseServices.ts
- service managementuseConfigMaps.ts
- config map managementuseSecrets.ts
- secret managementuseDaemonSets.ts
- daemon set managementuseReplicaSets.ts
- replica set management with scalinguseJobs.ts
- job management (new)🌐 Namespace Support
_all
namespace: Enables cluster-wide resource viewing usingForAllNamespaces
query variantsdefault
namespace when_all
is selected🔧 Component Updates
components/dashboard-layout.tsx
- updated to use new namespace contextcomponents/namespace-switcher.tsx
- enhanced with_all
support and better UIcomponents/templates/template-dialog.tsx
- migrated to use mutation hookscomponents/resources/pods.tsx
- updated to use new namespace context📦 Import Updates
@kubernetesjs/react
generated hooksusePreferredNamespace()
across componentsMutation
suffix)Key Features
Namespace Context
Cluster-wide Queries
Preserved Signatures
All existing hook signatures are preserved to maintain backward compatibility:
Testing
_all
namespace triggers cluster-wide queriesdefault
namespace appropriatelyMigration Benefits
Breaking Changes
None - all existing hook signatures and behavior are preserved.
Link to Devin run: https://app.devin.ai/sessions/20e9e58bb4df43d38e1a80ba6e8ac1ad
Requested by: Dan Lynch (pyramation@gmail.com)